package com.mojo.webflux;

import java.util.Observable;

/**
 * 观察者示例,理解响应式编程
 *
 * @author <a href="mailto:mojo_jj@163.com">Mojo</a>
 */
public class ObserverDemo extends Observable {
    public static void main(String[] args) {
        ObserverDemo observer = new ObserverDemo();
        observer.addObserver((o,arg)->{
            System.out.println("观察者通知");
        });
        observer.addObserver((o,arg)->{
            System.out.println("观察者");
        });
        //设置变化
        observer.setChanged();
        //通知
        observer.notifyObservers();

    }
}
